include Make.defs

NAME=ipodfork
MAIN=$(NAME)
MANIFEST=manifest.mf
VERSION=0.1
USE_1_5=./setjvm.sh 1.5
USE_1_3=./setjvm.sh 1.3
ANT=$(USE_1_5) && ant

.classpath: lib Makefile
	rm -f $@
	touch $@
	echo .$(SEP)`ls lib/*.jar | xargs | sed -e "s/ /$(SEP)/g"` > $@


%.class:%.java .classpath
	$(USE_1_3)
	javac -target 1.3 -source 1.3 -g -classpath `cat .classpath`  $<

%.run:%.class .classpath
	$(USE_1_3)
	java -classpath `cat .classpath` $* -debug

%.app: %.jar
	rm -rf $@
	ant -Dname=$* -Dmainclass=$* -Djar=$< build.app

%.app.zip:%.app
	zip -r $@ $<

%.exe: %.jar
	ant -Dname=$* -Dmainclass=$* -Djar=$< build.exe

%.tar.gz:%.tar
	gzip -9 -f $<

all: Version.java .classpath
	javac -target 1.3 -source 1.3 -g -classpath `cat .classpath` *.java

Version.java: Makefile
	rm -f $@
	touch $@
	echo "final class Version {" >> $@
	echo "  public final static double VERSION = $(VERSION);" >> $@
	echo "}" >> $@

run: $(MAIN).run
jar: $(NAME).jar
app: $(NAME).app
zip: $(NAME).app.zip
exe: $(NAME).exe

release: $(NAME).exe $(NAME).app.zip $(NAME).tar.gz

upload: release index.php
	$(ANT) upload


$(NAME).tar: Makefile *.java build.xml README template.jsmooth r lib setjvm.sh
	tar cfv $@ $^

$(NAME).jar: $(MAIN).class $(MANIFEST)
	jar cfm $@ $(MANIFEST) *.class *.properties
	mkdir -p t
	cp lib/*.jar t
	cd t && \
	for f in `ls *.jar`; do \
		echo === $$f ===; \
		jar xf $$f; \
	done && \
	rm *.jar && \
	jar ufm ../$(NAME).jar ../$(MANIFEST) com javax net org && \
	cd ..
	rm -rf t

$(MANIFEST): Makefile
	echo "Main-class: $(MAIN)" > $@

distclean:
	rm -rf $(NAME).tar $(NAME).tar.gz $(NAME).app $(NAME).app.zip \
		$(NAME).exe $(MANIFEST) $(NAME).jar

clean:
	rm -f *~ *.class

allclean: clean distclean

# SPECIFIC

